/*
 * @Author: sympsel sympsel@outlook.com
 * @Date: 2025-09-30 08:05:09
 * @LastEditors: sympsel sympsel@outlook.com
 * @LastEditTime: 2025-09-30 19:55:27
 * @FilePath: \work25_9_30\src\test.cpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include "SinglyList.h"

// 尾插测试
void test1() {
    cout << "> Test push_back: " << endl;
    SinglyLinkedList<int> list;
    list.push_back(1);
    list.push_back(2);
    list.push_back(3);
    cout << list << endl;
    cout << "list size: " << list.size() << endl;
    cout << "list front: " << list.front() << endl;
    cout << "list tail: " << list.back() << endl;
}

void test2() {
    cout << "> Test push_front: " << endl;
    SinglyLinkedList<int> list;
    list.push_front(1);
    list.push_front(2);
    list.push_front(3);
    cout << "list size: " << list.size() << endl;
    cout << "list front: " << list.front() << endl;
    // cout << "list tail: " << list.back() << endl;
}

void test3() {
    cout << "> Test pop" << endl;
    SinglyLinkedList<int> list;
    for (int i = 0; i < 10; ++i) {
        list.push_back(i + 1);
    }
    cout << list << endl;
    list.pop_back();
    cout << list << endl;
    list.pop_front();
    cout << list << endl;
    cout << "list size: " << list.size() << endl;
    cout << "list front: " << list.front() << endl;
    cout << "list tail: " << list.back() << endl;
}

void test4() {
    cout << "> Test copy_constructor && assignment_constructor" << endl;
    SinglyLinkedList<int> list;
    for (int i = 0; i < 10; ++i) {
        list.push_back(i + 1);
    }
    SinglyLinkedList<int> list_copy(list);
    cout << "list: ";
    SinglyLinkedList<int>::print(list);
    cout << "list_copy: ";
    SinglyLinkedList<int>::print(list_copy);
    SinglyLinkedList<int> list_assign;
    list_assign.push_back(1);
    list_assign = list;
    cout << list_assign << endl;
}

void test5() {
    cout<< "> Test insert && erase" << endl;
    SinglyLinkedList<int> list;
    for (int i = 0; i < 10; ++i) {
        list.push_back(i + 1);
    }
    cout << list << endl;
    list.insert(11, 3);
    cout << list << endl;
    list.erase(3);
    cout << list << endl;
}

void test6() {

}

void test(void (*func)()) { func(); }

int main() {
    void (*funcs[])() = {test1, test2, test3, test4, test5};
    for (auto t : funcs) {
        t();
    }
    return 0;
}